<template>
  <div id="noticelist" > 


          <el-table :data="datalist" style="width: 100%" :row-class-name="tableRowClassName" 
           :border="true" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
          >

                 <el-table-column label="公告日期"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.startdate }} 至 {{ scope.row.enddate }}</span>
                    </template>
                </el-table-column>
                <el-table-column label="标题"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.title }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="内容"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.content }}</span>
                    </template>
                </el-table-column>
                 <el-table-column label="操作" align='center' >
                    <template slot-scope="scope">
                        <el-button size="mini"  type="primary"  plain class="button_class1" @click="mtk1_but(scope.row)">修改</el-button> 
                        <el-button size="mini"  type="primary"  plain class="button_class2" @click="delect_but(scope.row)">删除</el-button> 
                    </template>
                </el-table-column>

            </el-table>  


     <el-dialog title="修改公告" :visible.sync="mtk1"  width="500px" >
          <el-form ref="form"   label-width="80px" style="width:100%;">

                <el-form-item label="选择日期" >
                 <el-date-picker type="date"  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.startdate"  style="width:100%;"></el-date-picker>
               </el-form-item>
               <el-form-item label="结束日期" >
                 <el-date-picker type="date"  placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  v-model="mtk1_form.enddate"  style="width:100%;"></el-date-picker>
               </el-form-item>
                <el-form-item label="添加标题">
                    <el-input v-model="mtk1_form.title" placeholder="必填"></el-input>
                </el-form-item> 
                 <el-form-item label="添加内容">
                    <el-input v-model="mtk1_form.content" type="textarea" :rows="4" placeholder="必填"></el-input>
                </el-form-item>

         </el-form>
          <div style="text-align: center;width:70%;margin:auto;">
                  <el-button type="primary" class="custom_color_button" style="width:80%;" @click="mtk1_but_qr()">确认</el-button>
          </div>

   </el-dialog> 
 


   </div>
</template>

<script>
export default {
   name: 'noticelist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度
        my_id:'',
        mtk1:false,
        mtk1_form:{
            startdate:'',
            enddate:'',
            title:'',
            content:''
        }
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 293
      
  },
  mounted (){
   
  },
  methods: {
    mtk1_but(row){
         this.my_id = row.id
         this.mtk1_form.title = row.title
         this.mtk1_form.content = row.content
         this.mtk1_form.startdate = row.startdate
         this.mtk1_form.enddate = row.enddate
         this.mtk1 = true
    },
    mtk1_but_qr(){
        this.post("/newspaper/updateOpenScreen", {
                id:this.my_id,
                title:this.mtk1_form.title,
                content:this.mtk1_form.content,
                startdate:this.mtk1_form.startdate,
                enddate:this.mtk1_form.enddate,
            }).then(res => {
                if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.mtk1 = false
                    this.$emit('up_list_fun')
                }else {
                this.open1(res.message,'warning')
                }

       })
    },
   delect_but(row){
         this.my_id = row.id
        this.$confirm('是否删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
             this.post("/newspaper/delOpenScreen", {
                    id:this.my_id,
                }).then(res => {
                    if(res.error_code == 0){
                      this.open1(res.result,'success')  //提示框
                      this.$emit('up_list_fun')
                      this.my_id = ''
                    }else {
                    this.open1(res.message,'warning')
                    }

              })
        })


    },

  }
}
</script>


<style scoped>

</style>